import * as signalR from '@aspnet/signalr';
import BASE from '@/utils/base'
const socket = new signalR.HubConnectionBuilder()
    .withUrl(`${BASE.IP}/chatHub`, {
        skipNegotiation: true,
        transport: signalR.HttpTransportType.WebSockets
      })
      .configureLogging(signalR.LogLevel.Information)
      .build();//使用你们后台给你的地址替换

//  自动重连
async function start() {
    try {
        await socket.start();
    } catch (err) {
        setTimeout(() => start(), 1000);
    }
}

socket.onclose(async () => {
    await start();
});

export default socket